<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>消费记录</title>
    <meta name="viewport" content="user-scalable=no">
    <meta name="format-detection" content="telephone=no">
	<meta http-equiv="x-rim-auto-match" content="none"> 
  	<meta http-equiv="pragma" content="no-cache">
  	<meta http-equiv="cache-control" content="no-cache">
  	<meta http-equiv="expires" content="0">
  	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
  	<meta http-equiv="description" content="This is my page">
    <link rel="stylesheet" type="text/css" href="static/weixin/css/common.css">
    <link rel="stylesheet" type="text/css" href="static/weixin/font/css/font-awesome.css">
    <link rel="stylesheet" href="static/weixin/plug/weui/css/weui.css">
    <script type="text/javascript" src="static/weixin/js/myJs.js"></script>
  </head>
  <body>
	<div class="page">
		<ul class="order_ul" id="list">
			<!-- <li>
				<p class='order_time'>
					<span>18111050661178339882</span>
					<span class='float_right'>2018-01-01 12:00:00</span>
				</p>
				<a href="./weixin/vip/getOrderDetails?djid=123">
				<p class='order_name'>A级-水晶富士（大）A级-水晶富士（大）A级-水晶富士（大）A级-水晶富士（大）A级-水晶富士（大）A级-水晶富士（大）A级-水晶富士（大）</p>
				<span class='order_num'>×2</span>
				<p class='order_total'>共2件商品 总价：<span class='order_price'>￥37.66</span><i class='fa fa-angle-right'></i></p>
				</a>
				<a href='tel:10086' class='order_relationship'>联系店家</a>
			</li> -->
		</ul>
	</div>
	<div class="weui-loadmore">
		<i class="weui-loading"></i> <span class="weui-loadmore__tips">正在加载</span>
	</div>
</body>
<script type="text/javascript" src="static/weixin/js/jquery-2.1.3.min.js"></script>
<script type="text/javascript">
	var isEnd = true;
	var page_index = 1;
	
	var update = function () {
        //判断加载是否完成
        //isEnd = false;
        console.log("加载")
	    $.ajax({
			type: "get",
			url: '<%=basePath%>weixin/vip/getOrders?tm='+new Date().getTime(),
		   	data: {openid: '${pd.openid}',currentPage: page_index, pageSize: '10'},
			dataType:'json',
			cache: false,
			success: function(rs){
				if (rs.data.success) {
					if (rs.data.data.total == 0) {
						$("#list").append("<li> <span class='interal_detail'>还没有记录噢</span></li>");
						$(".weui-loadmore").hide();
						return;
					}
					var datas = rs.data.data;
					var lists = datas.data;
					for (var n = 0; n < lists.length; n++) {
						if (lists[n].jfsr > 0) {
							lists[n].jfsr = "+" + lists[n].jfsr;
						}
						var time = lists[n].created.substring(0,lists[n].created.indexOf(":")+3);
						$("#list").append("<li><p class='order_time'><span>编号:" + lists[n].djbh + "</span>"
							+ "<span class='float_right'>"  + time + "</span></p>"
							+ "<span class='order_name'>" + lists[n].jgmc + "</span>"
							+ "<span class='order_num'>" + lists[n].name +"</span>"
							+ "<a href='./weixin/vip/getOrderDetails?djid=" + lists[n].djid + "&djbh="+lists[n].djbh+"&je="+lists[n].je+"&time="+time+"'>"
							+ "<p class='order_total'>共" + lists[n].jils + "件商品 总价：<span class='order_price'>￥" + lists[n].je + "</span><i class='fa fa-angle-right'></i></p></a>"
							+ "<a href='tel:" + lists[n].dianh + "' class='order_relationship'>联系店家</a></li>");
					}
					if (datas.totalPage > 1 && datas.totalPage > datas.currentPage){
						isEnd = false;
					} else {
						isEnd = true;
						$(".weui-loadmore").hide();
					}
				} else {
                    $.toast(rs.data.msg, "text");
                    $(".weui-loadmore").hide();
                }
			},
			error: function(){
				$.toast("程序异常", "text");
				return;
			}
		});
    };
    update();
	/*初始化*/
	$(window).scroll(function () {
	    if (isEnd == true) {
	        return;
	    }
	    // 当滚动到最底部以上100像素时， 加载新内容
	    // 核心代码
	    if ($(document).height() - $(this).scrollTop() - $(this).height() < 10) {
	        //console.log(page_index);
	        page_index = page_index + 1;
	        update();
	        isEnd = true;
	    }
	});

</script>
</html>
